﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FOModels.Company;
using DataAccess.Company;
using System.Data;
namespace Bussiness.Company
{
    public class CompanyBLL
    {
        private CompanyDAL dal;
        public CompanyBLL()
        {
            dal = new CompanyDAL();
        }
        public List<CompanyModels> getPartnerList(int langid)
        {
            List<CompanyModels> list = new List<CompanyModels>();
            CompanyModels fur;
            DataTable tb = dal.getPartnerList(langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CompanyModels();
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    fur.CompanyLogo = row["CompanyLogo"].ToString();
                    fur.Website = row["Website"].ToString();
                    fur.Phone = row["Phone"].ToString();
                    fur.Active = bool.Parse(row["Active"].ToString());
                    fur.ActiveHome = bool.Parse(row["ActiveHome"].ToString());
                    fur.Name = row["Name"].ToString();
                    fur.Address = row["Address"].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<CompanyModels> getCompany(int langid)
        {
            List<CompanyModels> list = new List<CompanyModels>();
            CompanyModels fur;
            DataTable tb = dal.getCompany(langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CompanyModels();
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    fur.CompanyLogo = row["CompanyLogo"].ToString();
                    fur.Website = row["Website"].ToString();
                    fur.Phone = row["Phone"].ToString();
                    fur.Active = bool.Parse(row["Active"].ToString());
                    fur.ActiveHome = bool.Parse(row["ActiveHome"].ToString());
                    fur.Name = row["Name"].ToString();
                    fur.Address = row["Address"].ToString();
                    fur.FlagImage = row["FlagImage"].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public CompanyModels getCompanybyID(int CompanyID, int langid)
        {

            CompanyModels fur = new CompanyModels();
            DataTable tb = dal.getCompanybyID(CompanyID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    fur.CompanyLogo = row["CompanyLogo"].ToString();
                    fur.Website = row["Website"].ToString();
                    fur.Phone = row["Phone"].ToString();
                    fur.Active = bool.Parse(row["Active"].ToString());
                    fur.ActiveHome = bool.Parse(row["ActiveHome"].ToString());
                    fur.Name = row["Name"].ToString();
                    fur.Address = row["Address"].ToString();
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public CompanyModels getTOP1Company()
        {

            CompanyModels fur = new CompanyModels();
            DataTable tb = dal.getTOP1Company();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    fur.CompanyLogo = row["CompanyLogo"].ToString();
                    fur.Website = row["Website"].ToString();
                    fur.Phone = row["Phone"].ToString();
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public TableTermInterestModels getTermInterestID(int TableTermInterestID)
        {

            TableTermInterestModels fur = new TableTermInterestModels();
            DataTable tb = dal.getTermInterestID(TableTermInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableTermInterestID = int.Parse(row["TableTermInterestID"].ToString());
                    fur.Month = int.Parse(row["Month"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.InterestEUR = float.Parse(row["InterestEUR"].ToString());
                    fur.InterestUSD = float.Parse(row["InterestUSD"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public TableTermDemandInterest getTermDemandInterestID(int TableTermDemandInterestID)
        {

            TableTermDemandInterest fur = new TableTermDemandInterest();
            DataTable tb = dal.getTermDemandInterestID(TableTermDemandInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableTermDemandInterestID = int.Parse(row["TableTermDemandInterestID"].ToString());
                    fur.Month = int.Parse(row["Month"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.InterestEUR = float.Parse(row["InterestEUR"].ToString());
                    fur.InterestUSD = float.Parse(row["InterestUSD"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public TableHomeLoanEquityInterestModels getTableHomeLoanEquityInterestID(int TableHomeLoanEquityInterestID)
        {

            TableHomeLoanEquityInterestModels fur = new TableHomeLoanEquityInterestModels();
            DataTable tb = dal.getTableHomeLoanEquityInterestID(TableHomeLoanEquityInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableHomeLoanEquityInterestID = int.Parse(row["TableHomeLoanEquityInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public TableHomeLoanMortgageInterestModels getTableHomeLoanMortgageInterestID(int TableHomeLoanMortgageInterestID)
        {

            TableHomeLoanMortgageInterestModels fur = new TableHomeLoanMortgageInterestModels();
            DataTable tb = dal.getTableHomeLoanMortgageInterestID(TableHomeLoanMortgageInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableHomeLoanMortgageInterestID = int.Parse(row["TableHomeLoanMortgageInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public TableCarLoanEquityInterestModels getTableCarLoanEquityInterestID(int TableHomeLoanMortgageInterestID)
        {

            TableCarLoanEquityInterestModels fur = new TableCarLoanEquityInterestModels();
            DataTable tb = dal.getTableCarLoanEquityInterestID(TableHomeLoanMortgageInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableCarLoanEquityInterestID = int.Parse(row["TableCarLoanEquityInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public TableHomeCarMortgageInterestModels getTableCarLoanMortgageInterestID(int TableHomeLoanMortgageInterestID)
        {

            TableHomeCarMortgageInterestModels fur = new TableHomeCarMortgageInterestModels();
            DataTable tb = dal.getTableCarLoanMortgageInterestID(TableHomeLoanMortgageInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableCarLoanMortgageInterestID = int.Parse(row["TableCarLoanMortgageInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public List<TableTermInterestModels> getTableTermInterestbyComID(int CompanyID)
        {

            List<TableTermInterestModels> list = new List<TableTermInterestModels>();
            TableTermInterestModels fur;
            DataTable tb = dal.getTableTermInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableTermInterestModels();
                    fur.TableTermInterestID = int.Parse(row["TableTermInterestID"].ToString());
                    fur.Month = int.Parse(row["Month"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.InterestEUR = float.Parse(row["InterestEUR"].ToString());
                    fur.InterestUSD = float.Parse(row["InterestUSD"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public List<TableHomeLoanEquityInterestModels> getTableHomeLoanEquityInterestbyComID(int CompanyID)
        {

            List<TableHomeLoanEquityInterestModels> list = new List<TableHomeLoanEquityInterestModels>();
            TableHomeLoanEquityInterestModels fur;
            DataTable tb = dal.getTableHomeLoanEquityInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableHomeLoanEquityInterestModels();
                    fur.TableHomeLoanEquityInterestID = int.Parse(row["TableHomeLoanEquityInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public List<TableHomeLoanMortgageInterestModels> getTableHomeLoanMortgageInterestbyComID(int CompanyID)
        {

            List<TableHomeLoanMortgageInterestModels> list = new List<TableHomeLoanMortgageInterestModels>();
            TableHomeLoanMortgageInterestModels fur;
            DataTable tb = dal.getTableHomeLoanMortgageInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableHomeLoanMortgageInterestModels();
                    fur.TableHomeLoanMortgageInterestID = int.Parse(row["TableHomeLoanMortgageInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public List<TableCarLoanEquityInterestModels> getTableCarLoanEquityInterestbyComID(int CompanyID)
        {

            List<TableCarLoanEquityInterestModels> list = new List<TableCarLoanEquityInterestModels>();
            TableCarLoanEquityInterestModels fur;
            DataTable tb = dal.getTableCarLoanEquityInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableCarLoanEquityInterestModels();
                    fur.TableCarLoanEquityInterestID = int.Parse(row["TableCarLoanEquityInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public List<TableHomeCarMortgageInterestModels> getTableCarLoanMortgageInterestbyComID(int CompanyID)
        {

            List<TableHomeCarMortgageInterestModels> list = new List<TableHomeCarMortgageInterestModels>();
            TableHomeCarMortgageInterestModels fur;
            DataTable tb = dal.getTableCarLoanMortgageInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableHomeCarMortgageInterestModels();
                    fur.TableCarLoanMortgageInterestID = int.Parse(row["TableCarLoanMortgageInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public List<TableTermDemandInterest> getTableTermDemandInterestbyComID(int CompanyID)
        {

            List<TableTermDemandInterest> list = new List<TableTermDemandInterest>();
            TableTermDemandInterest fur;
            DataTable tb = dal.getTableTermDemandInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableTermDemandInterest();
                    fur.TableTermDemandInterestID = int.Parse(row["TableTermDemandInterestID"].ToString());
                    fur.Month = int.Parse(row["Month"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.InterestEUR = float.Parse(row["InterestEUR"].ToString());
                    fur.InterestUSD = float.Parse(row["InterestUSD"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public int InsertCompany(CompanyModels models)
        {
            if (dal.InsertCompany(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertCompanyLang(CompanyModels models, int langid)
        {
            if (dal.InsertCompanyLang(models, langid) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateCompany(CompanyModels models, int langid)
        {
            if (dal.UpdateCompany(models) > 0 && dal.UpdateCompanyLang(models, langid) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteCompany(int CompanyID)
        {
            if (dal.DeleteCompany(CompanyID) > 0 && dal.DeleteCompanyLang(CompanyID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertTableTermInterest(TableTermInterestModels models)
        {
            if (dal.InsertTableTermInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableTermInterest(TableTermInterestModels models)
        {
            if (dal.UpdateTableTermInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableTermInterest(int TableTermInterestID)
        {
            if (dal.DeleteTableTermInterest(TableTermInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertTableDemandTermInterest(TableTermDemandInterest models)
        {
            if (dal.InsertTableDemandTermInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableTermDemandInterest(TableTermDemandInterest models)
        {
            if (dal.UpdateTableTermDemandInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableTermDemandInterest(int TableTermDemandInterestID)
        {
            if (dal.DeleteTableTermDemandInterest(TableTermDemandInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        /// <summary>
        /// LOAN EQUITY
        /// </summary>
        /// <param name="models"></param>
        /// <returns></returns>
        /// 

        public int InsertTableHomeLoanEquityInterest(TableHomeLoanEquityInterestModels models)
        {
            if (dal.InsertTableHomeLoanEquityInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableHomeLoanEquityInterest(TableHomeLoanEquityInterestModels models)
        {
            if (dal.UpdateTableHomeLoanEquityInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableHomeLoanEquityInterest(int TableHomeLoanEquityInterestID)
        {
            if (dal.DeleteTableHomeLoanEquityInterest(TableHomeLoanEquityInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        /// <summary>
        /// CarLoan EQUITY
        /// </summary>
        /// <param name="models"></param>
        /// <returns></returns>
        /// 

        public int InsertTableCarLoanEquityInterest(TableCarLoanEquityInterestModels models)
        {
            if (dal.InsertTableCarLoanEquityInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableCarLoanEquityInterest(TableCarLoanEquityInterestModels models)
        {
            if (dal.UpdateTableCarLoanEquityInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableCarLoanEquityInterest(int TableCarLoanEquityInterestID)
        {
            if (dal.DeleteTableCarLoanEquityInterest(TableCarLoanEquityInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        /// <summary>
        /// CAR LOAN MORTGAGE
        /// </summary>
        /// <param name="models"></param>
        /// <returns></returns>
        /// 
        public int InsertTableCarLoanMortgageInterest(TableHomeCarMortgageInterestModels models)
        {
            if (dal.InsertTableCarLoanMortgageInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableCarLoanMortgageInterest(TableHomeCarMortgageInterestModels models)
        {
            if (dal.UpdateTableCarLoanMortgageInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableCarLoanMortgageInterest(int TableCarLoanMortgageInterestID)
        {
            if (dal.DeleteTableCarLoanMortgageInterest(TableCarLoanMortgageInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertTableHomeLoanMortgageInterest(TableHomeLoanMortgageInterestModels models)
        {
            if (dal.InsertTableHomeLoanMortgageInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableHomeLoanMortgageInterest(TableHomeLoanMortgageInterestModels models)
        {
            if (dal.UpdateTableHomeLoanMortgageInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableHomeLoanMortgageInterest(int TableHomeLoanMortgageInterestID)
        {
            if (dal.DeleteTableHomeLoanMortgageInterest(TableHomeLoanMortgageInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }


        ///SHORT TERN LOAN
        ///
        public List<TableShortTermLoanInterestModels> getTableShortTermLoanInterestbyComID(int CompanyID)
        {

            List<TableShortTermLoanInterestModels> list = new List<TableShortTermLoanInterestModels>();
            TableShortTermLoanInterestModels fur;
            DataTable tb = dal.getTableShortTermLoanInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableShortTermLoanInterestModels();
                    fur.TableShortTermLoanInterestID = int.Parse(row["TableShortTermLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public TableShortTermLoanInterestModels getTableShortTermLoanInterestID(int TableShortTermLoanInterestID)
        {

            TableShortTermLoanInterestModels fur = new TableShortTermLoanInterestModels();
            DataTable tb = dal.getTableShortTermLoanInterestID(TableShortTermLoanInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableShortTermLoanInterestID = int.Parse(row["TableShortTermLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertTableShortTermLoanInterest(TableShortTermLoanInterestModels models)
        {
            if (dal.InsertTableShortTermLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableShortTermLoanInterest(TableShortTermLoanInterestModels models)
        {
            if (dal.UpdateTableShortTermLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableShortTermLoanInterest(int TableShortTermLoanInterestID)
        {
            if (dal.DeleteTableShortTermLoanInterest(TableShortTermLoanInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        ///LONG TERN LOAN
        ///
        public List<TableLongTermLoanInterestModels> getTableLongTermLoanInterestbyComID(int CompanyID)
        {

            List<TableLongTermLoanInterestModels> list = new List<TableLongTermLoanInterestModels>();
            TableLongTermLoanInterestModels fur;
            DataTable tb = dal.getTableLongTermLoanInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableLongTermLoanInterestModels();
                    fur.TableLongTermLoanInterestID = int.Parse(row["TableLongTermLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public TableLongTermLoanInterestModels getTableLongTermLoanInterestID(int TableLongTermLoanInterestID)
        {

            TableLongTermLoanInterestModels fur = new TableLongTermLoanInterestModels();
            DataTable tb = dal.getTableLongTermLoanInterestID(TableLongTermLoanInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableLongTermLoanInterestID = int.Parse(row["TableLongTermLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertTableLongTermLoanInterest(TableLongTermLoanInterestModels models)
        {
            if (dal.InsertTableLongTermLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableLongTermLoanInterest(TableLongTermLoanInterestModels models)
        {
            if (dal.UpdateTableLongTermLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableLongTermLoanInterest(int TableLongTermLoanInterestID)
        {
            if (dal.DeleteTableLongTermLoanInterest(TableLongTermLoanInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        ///Financial Leasing LOAN
        ///
        public List<TableFinancialLeasingLoanInterestModels> getTableFinancialLeasingLoanInterestbyComID(int CompanyID)
        {

            List<TableFinancialLeasingLoanInterestModels> list = new List<TableFinancialLeasingLoanInterestModels>();
            TableFinancialLeasingLoanInterestModels fur;
            DataTable tb = dal.getTableFinancialLeasingLoanInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableFinancialLeasingLoanInterestModels();
                    fur.TableFinancialLeasingLoanInterestID = int.Parse(row["TableFinancialLeasingLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public TableFinancialLeasingLoanInterestModels getTableFinancialLeasingLoanInterestID(int TableFinancialLeasingLoanInterestID)
        {

            TableFinancialLeasingLoanInterestModels fur = new TableFinancialLeasingLoanInterestModels();
            DataTable tb = dal.getTableFinancialLeasingLoanInterestID(TableFinancialLeasingLoanInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableFinancialLeasingLoanInterestID = int.Parse(row["TableFinancialLeasingLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertTableFinancialLeasingLoanInterest(TableFinancialLeasingLoanInterestModels models)
        {
            if (dal.InsertTableFinancialLeasingLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableFinancialLeasingLoanInterest(TableFinancialLeasingLoanInterestModels models)
        {
            if (dal.UpdateTableFinancialLeasingLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableFinancialLeasingLoanInterest(int TableFinancialLeasingLoanInterestID)
        {
            if (dal.DeleteTableFinancialLeasingLoanInterest(TableFinancialLeasingLoanInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        ///Capital LOAN
        ///
        public List<TableCapitalLoanInterestModels> getTableCapitalLoanInterestbyComID(int CompanyID)
        {

            List<TableCapitalLoanInterestModels> list = new List<TableCapitalLoanInterestModels>();
            TableCapitalLoanInterestModels fur;
            DataTable tb = dal.getTableCapitalLoanInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableCapitalLoanInterestModels();
                    fur.TableCapitalLoanInterestID = int.Parse(row["TableCapitalLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public TableCapitalLoanInterestModels getTableCapitalLoanInterestID(int TableCapitalLoanInterestID)
        {

            TableCapitalLoanInterestModels fur = new TableCapitalLoanInterestModels();
            DataTable tb = dal.getTableCapitalLoanInterestID(TableCapitalLoanInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableCapitalLoanInterestID = int.Parse(row["TableCapitalLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertTableCapitalLoanInterest(TableCapitalLoanInterestModels models)
        {
            if (dal.InsertTableCapitalLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableCapitalLoanInterest(TableCapitalLoanInterestModels models)
        {
            if (dal.UpdateTableCapitalLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableCapitalLoanInterest(int TableCapitalLoanInterestID)
        {
            if (dal.DeleteTableCapitalLoanInterest(TableCapitalLoanInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        // Consumer Loan

        public List<TableConsumerLoanInterestModels> getTableConsumerLoanInterestbyComID(int CompanyID)
        {

            List<TableConsumerLoanInterestModels> list = new List<TableConsumerLoanInterestModels>();
            TableConsumerLoanInterestModels fur;
            DataTable tb = dal.getTableConsumerLoanInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableConsumerLoanInterestModels();
                    fur.TableConsumerLoanInterestID = int.Parse(row["TableConsumerLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public TableConsumerLoanInterestModels getTableConsumerLoanInterestID(int TableConsumerLoanInterestID)
        {

            TableConsumerLoanInterestModels fur = new TableConsumerLoanInterestModels();
            DataTable tb = dal.getTableConsumerLoanInterestID(TableConsumerLoanInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableConsumerLoanInterestID = int.Parse(row["TableConsumerLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertTableConsumerLoanInterest(TableConsumerLoanInterestModels models)
        {
            if (dal.InsertTableConsumerLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableConsumerLoanInterest(TableConsumerLoanInterestModels models)
        {
            if (dal.UpdateTableConsumerLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableConsumerLoanInterest(int TableConsumerLoanInterestID)
        {
            if (dal.DeleteTableConsumerLoanInterest(TableConsumerLoanInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }


        // EducationLoan

        public List<TableEducationLoanInterestModels> getTableEducationLoanInterestbyComID(int CompanyID)
        {

            List<TableEducationLoanInterestModels> list = new List<TableEducationLoanInterestModels>();
            TableEducationLoanInterestModels fur;
            DataTable tb = dal.getTableEducationLoanInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableEducationLoanInterestModels();
                    fur.TableEducationLoanInterestID = int.Parse(row[0].ToString());
                    fur.Years = int.Parse(row[1].ToString());
                    fur.InterestVND = float.Parse(row[2].ToString());
                    fur.CompanyID = int.Parse(row[3].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public TableEducationLoanInterestModels getTableEducationLoanInterestID(int TableEducationLoanInterestID)
        {

            TableEducationLoanInterestModels fur = new TableEducationLoanInterestModels();
            DataTable tb = dal.getTableEducationLoanInterestID(TableEducationLoanInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableEducationLoanInterestID = int.Parse(row[0].ToString());
                    fur.Years = int.Parse(row[1].ToString());
                    fur.InterestVND = float.Parse(row[2].ToString());
                    fur.CompanyID = int.Parse(row[3].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertTableEducationLoanInterest(TableEducationLoanInterestModels models)
        {
            if (dal.InsertTableEducationLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableEducationLoanInterest(TableEducationLoanInterestModels models)
        {
            if (dal.UpdateTableEducationLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableEducationLoanInterest(int TableEducationLoanInterestID)
        {
            if (dal.DeleteTableEducationLoanInterest(TableEducationLoanInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        // OverdraftLoan

        public List<TableOverdraftLoanInterestModels> getTableOverdraftLoanInterestbyComID(int CompanyID)
        {

            List<TableOverdraftLoanInterestModels> list = new List<TableOverdraftLoanInterestModels>();
            TableOverdraftLoanInterestModels fur;
            DataTable tb = dal.getTableOverdraftLoanInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableOverdraftLoanInterestModels();
                    fur.TableOverdraftLoanInterestID = int.Parse(row["TableOverdraftLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public TableOverdraftLoanInterestModels getTableOverdraftLoanInterestID(int TableOverdraftLoanInterestID)
        {

            TableOverdraftLoanInterestModels fur = new TableOverdraftLoanInterestModels();
            DataTable tb = dal.getTableOverdraftLoanInterestID(TableOverdraftLoanInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableOverdraftLoanInterestID = int.Parse(row["TableOverdraftLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertTableOverdraftLoanInterest(TableOverdraftLoanInterestModels models)
        {
            if (dal.InsertTableOverdraftLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableOverdraftLoanInterest(TableOverdraftLoanInterestModels models)
        {
            if (dal.UpdateTableOverdraftLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableOverdraftLoanInterest(int TableOverdraftLoanInterestID)
        {
            if (dal.DeleteTableOverdraftLoanInterest(TableOverdraftLoanInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        // ConsumerInstallmentLoan

        public List<TableConsumerInstallmentLoanInterestModels> getTableConsumerInstallmentLoanInterestbyComID(int CompanyID)
        {

            List<TableConsumerInstallmentLoanInterestModels> list = new List<TableConsumerInstallmentLoanInterestModels>();
            TableConsumerInstallmentLoanInterestModels fur;
            DataTable tb = dal.getTableConsumerInstallmentLoanInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableConsumerInstallmentLoanInterestModels();
                    fur.TableConsumerInstallmentLoanInterestID = int.Parse(row["TableConsumerInstallmentLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public TableConsumerInstallmentLoanInterestModels getTableConsumerInstallmentLoanInterestID(int TableConsumerInstallmentLoanInterestID)
        {

            TableConsumerInstallmentLoanInterestModels fur = new TableConsumerInstallmentLoanInterestModels();
            DataTable tb = dal.getTableConsumerInstallmentLoanInterestID(TableConsumerInstallmentLoanInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableConsumerInstallmentLoanInterestID = int.Parse(row["TableConsumerInstallmentLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertTableConsumerInstallmentLoanInterest(TableConsumerInstallmentLoanInterestModels models)
        {
            if (dal.InsertTableConsumerInstallmentLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableConsumerInstallmentLoanInterest(TableConsumerInstallmentLoanInterestModels models)
        {
            if (dal.UpdateTableConsumerInstallmentLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableConsumerInstallmentLoanInterest(int TableConsumerInstallmentLoanInterestID)
        {
            if (dal.DeleteTableConsumerInstallmentLoanInterest(TableConsumerInstallmentLoanInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        // PersonalBusinessLoan

        public List<TablePersonalBusinessLoanInterestModels> getTablePersonalBusinessLoanInterestbyComID(int CompanyID)
        {

            List<TablePersonalBusinessLoanInterestModels> list = new List<TablePersonalBusinessLoanInterestModels>();
            TablePersonalBusinessLoanInterestModels fur;
            DataTable tb = dal.getTablePersonalBusinessLoanInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TablePersonalBusinessLoanInterestModels();
                    fur.TablePersonalBusinessLoanInterestID = int.Parse(row["TablePersonalBusinessLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public TablePersonalBusinessLoanInterestModels getTablePersonalBusinessLoanInterestID(int TablePersonalBusinessLoanInterestID)
        {

            TablePersonalBusinessLoanInterestModels fur = new TablePersonalBusinessLoanInterestModels();
            DataTable tb = dal.getTablePersonalBusinessLoanInterestID(TablePersonalBusinessLoanInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TablePersonalBusinessLoanInterestID = int.Parse(row["TablePersonalBusinessLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertTablePersonalBusinessLoanInterest(TablePersonalBusinessLoanInterestModels models)
        {
            if (dal.InsertTablePersonalBusinessLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTablePersonalBusinessLoanInterest(TablePersonalBusinessLoanInterestModels models)
        {
            if (dal.UpdateTablePersonalBusinessLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTablePersonalBusinessLoanInterest(int TablePersonalBusinessLoanInterestID)
        {
            if (dal.DeleteTablePersonalBusinessLoanInterest(TablePersonalBusinessLoanInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        // HomeEquityLoan

        public List<TableHomeEquityLoanInterestModels> getTableHomeEquityLoanInterestbyComID(int CompanyID)
        {

            List<TableHomeEquityLoanInterestModels> list = new List<TableHomeEquityLoanInterestModels>();
            TableHomeEquityLoanInterestModels fur;
            DataTable tb = dal.getTableHomeEquityLoanInterestbyComID(CompanyID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new TableHomeEquityLoanInterestModels();
                    fur.TableHomeEquityLoanInterestID = int.Parse(row["TableHomeEquityLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                    list.Add(fur);

                }
                return list;
            }
            else
            {
                return null;
            }

        }
        public TableHomeEquityLoanInterestModels getTableHomeEquityLoanInterestID(int TableHomeEquityLoanInterestID)
        {

            TableHomeEquityLoanInterestModels fur = new TableHomeEquityLoanInterestModels();
            DataTable tb = dal.getTableHomeEquityLoanInterestID(TableHomeEquityLoanInterestID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.TableHomeEquityLoanInterestID = int.Parse(row["TableHomeEquityLoanInterestID"].ToString());
                    fur.Years = int.Parse(row["Years"].ToString());
                    fur.InterestVND = float.Parse(row["InterestVND"].ToString());
                    fur.CompanyID = int.Parse(row["CompanyID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertTableHomeEquityLoanInterest(TableHomeEquityLoanInterestModels models)
        {
            if (dal.InsertTableHomeEquityLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateTableHomeEquityLoanInterest(TableHomeEquityLoanInterestModels models)
        {
            if (dal.UpdateTableHomeEquityLoanInterest(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteTableHomeEquityLoanInterest(int TableHomeEquityLoanInterestID)
        {
            if (dal.DeleteTableHomeEquityLoanInterest(TableHomeEquityLoanInterestID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

    }
}
